Repository navigation
Conversation
The value model takes a UUID, but no conformance case held one. So nothing checked that Rust, Go, and TypeScript write the same UUID frame and derive the same equality term. record-scalars-v1 now has three UUID cases: an ordinary UUID, the nil UUID, and the max UUID. The Rust engine froze the frame, equality term, and ciphertext of each. Two cases list the same UUID in other letter cases. Five new refusals show that the engine converts nothing to or from a UUID. A UUID field refuses a string, bytes, or a null. A bytes field and a string field each refuse a UUID. Native Rust and Go run every case. The TypeScript value bridge checks the frames, from each spelling. The TypeScript runner of the whole profile waits on the addon storing a UUID (#1996). An update of the frozen file now keeps the ciphertext of a case whose frame and equality term have not changed. So adding a case adds one entry. Refs #1821
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
Mutation testing (cargo-mutants,
|
coderdan
left a comment
There was a problem hiding this comment.
Review of this pull request: five findings. One is important: the update mode can no longer refresh a frozen ciphertext.
| case.id | ||
| ); | ||
| } | ||
| let kept = previous |
There was a problem hiding this comment.
Important. STACK_CONFORMANCE_UPDATE=1 can no longer refresh a frozen ciphertext. When a case's frame and equality term are unchanged, the update opens the old ciphertext with .unwrap() and writes it back (line 381). If the old ciphertext no longer opens, the update panics instead of writing a new one. Line 236 also panics through serde_json::from_slice(..).unwrap() when the old file no longer parses under deny_unknown_fields. So after a deliberate change to the ciphertext header, the only way to regenerate is to delete the expected file by hand.
Fix: fall back to the fresh artifact when the kept ciphertext fails to open, treat an unreadable previous file as missing, or add a full-regenerate option.
There was a problem hiding this comment.
Fixed in 1d3d3c6.
STACK_CONFORMANCE_UPDATE=1now opens a kept ciphertext first, through the scalar API and the record path, with nounwrap. If it does not open to the input, the update writes the fresh ciphertext and logs the case.- A previous expected file that does not parse is treated as missing. The update logs it and writes every artifact fresh.
STACK_CONFORMANCE_UPDATE=allwrites every artifact fresh. Any other value fails the test. The README describes both values.
How I tested the fallback, on the expected file in the worktree, restoring it with git checkout after each step:
- I changed one hex digit of the
uuidciphertext, then ran withSTACK_CONFORMANCE_UPDATE=1. The log saiduuid: the frozen ciphertext no longer opens (Aead); writing a fresh one. Onlyuuidchanged, and a check run then passed. - I replaced the file with
{"not": "artifacts"}and ran with=1. The log said the file does not parse, all 11 ciphertexts were written fresh, and a check run passed. - With
=all, all 11 ciphertexts changed, and a check run passed. - With
=1on the unchanged file, there was no diff.
| case.id | ||
| ); | ||
| output.cases.insert(case.id.clone(), artifact); | ||
| let written = if update { reference.clone() } else { artifact }; |
There was a problem hiding this comment.
Minor. In update mode, STACK_CONFORMANCE_OUTPUT now writes the kept old ciphertexts, while the producer field names the current crate version. A consumer that wants ciphertexts this build made, as the exchange profile does, gets old ones. Fix: write the fresh artifact to the output path, and use the kept one only for the expected file.
There was a problem hiding this comment.
Fixed in 1d3d3c6. The runner keeps two maps now. STACK_CONFORMANCE_OUTPUT gets the artifacts this run made. Only the expected file gets the kept ciphertexts.
I ran STACK_CONFORMANCE_UPDATE=1 with an output path: all 11 ciphertexts in the output differ from the kept ones in the expected file. The README says that the output never contains a kept ciphertext.
| use serde_json::json; | ||
| use stack_encrypt::dynamic::{self, frame::OwnedFrame, record, Fidelity, NoTargets, Op, Operand}; | ||
| use stack_encrypt::target::IndexSpec; | ||
| use stack_encrypt::value::Uuid; |
There was a problem hiding this comment.
Minor. The test now imports stack_encrypt::value::Uuid, which exists only with the uuid feature, but the file is gated only on feature = "dynamic". cargo test -p stack-encrypt --no-default-features --features dynamic fails with E0432. tests/value_bytes.rs gates on both features for this reason. Fix: gate on both, or gate only the UUID arms.
There was a problem hiding this comment.
Fixed in 1d3d3c6. Only the UUID parts are gated now: the value::Uuid import, parse_uuid, the uuid arms of the seal and open matches, and the spelling check. A build without uuid has no typed UUID. So it skips the three accepted UUID cases with a log line, and runs every other case, the five UUID refusals included. An update without the feature fails, because it would drop those entries.
cargo test -p stack-encrypt --no-default-features --features dynamic --test conformance builds and passes. Clippy with -D warnings is clean with that feature set and with --all-features --all-targets.
| 'record-scalars-v1/uuid', | ||
| ], | ||
| [ | ||
| 'VcUuid uppercase', |
There was a problem hiding this comment.
Minor. The TypeScript check hard-codes the UUID spellings instead of reading each case's spellings from the corpus, while the README (lines 62 and 288) says it writes every spelling. A spelling added to the corpus is checked by Rust and Go but not by the TypeScript bridge, and nothing notices. Fix: read spellings from the corpus, or have the parity test check that every corpus spelling has a matching input.
There was a problem hiding this comment.
Fixed in 1d3d3c6. frames.cjs no longer names any UUID. On a regenerate it reads the text and spellings of each accepted UUID case from record-scalars-v1.cases.json. It stores them under uuids in corpus-frames.json, so a check run still reads nothing outside the package.
It writes a VcUuid frame from each text and each spelling. I regenerated both fixtures.
The parity test has two new checks:
- The
uuidscopy must equal the UUID cases in the corpus. js-frames.jsonmust pin a frame for every text and spelling, with the right case andsame_as_corpus: true.
To check them, I added a spelling to uuid-max in the corpus without regenerating. Both checks failed. Then I restored the file.
| The engine converts nothing to or from a UUID. | ||
|
|
||
| Boolean equality is not admitted by the current engine. Boolean scalar | ||
| encryption, nullable records, other numeric kinds, bytes, JSON, EQL targets, |
There was a problem hiding this comment.
Minor. The profile text still lists "bytes" among the kinds that need later profiles, but this pull request adds query-uuid-for-bytes, a case whose field is bytes. Fix: say that bytes positives and bytes equality need later cases.
There was a problem hiding this comment.
Fixed in 1d3d3c6. The paragraph now says that bytes need accepted cases and frozen equality terms. It also says that the one bytes field in the profile only refuses a UUID. I split the list there into shorter sentences.
These changes address the review of the UUID cases. The scalar runner's update kept a frozen ciphertext and then failed when that ciphertext no longer opened. Now the update first checks that the kept ciphertext opens. If it does not, the update writes a fresh one. A previous file that does not parse keeps nothing. STACK_CONFORMANCE_UPDATE=all writes every artifact fresh. STACK_CONFORMANCE_OUTPUT always gets the artifacts this run made. The runner now builds without the uuid feature. Only the UUID arms need it, and a build without the feature skips the accepted UUID cases. The TypeScript frame suite reads each UUID case's text and spellings from the corpus, through its copy. The parity test fails when the copy differs from the corpus, or when a spelling has no pinned frame. The README says which bytes cases are still to come. Refs #1821
cipherstash-agent
left a comment
There was a problem hiding this comment.
Review attestation
Reviewed 1d3d3c6 · posted from Claude Code (scheduled routine) · claude-opus-5-5 · effort medium
Sources: code-review · claude-opus-5-5; mattpocock-skills:code-review standards and spec agents · claude-opus-5-5; review-cross-check verifiers · claude-opus-5-5
Skills: code-review, company-skills:rust-security, mattpocock-skills:code-review, company-skills:review-cross-check, company-skills:review-post
Findings (6): 6 minor — 6 inline.
rust-security found nothing to report: the Rust changes are test-only and use deterministic test keys. Earlier findings already raised in this PR's threads were not repeated. Findings left out because they turn on a design choice, or did not hold up at head, are not posted here.
Generated by Claude Code
| assert!( | ||
| case.spellings.is_empty() || case.input.kind == "uuid", | ||
| "{}: only a UUID input has other spellings", | ||
| case.id | ||
| ); | ||
| for spelling in &case.spellings { | ||
| assert!( | ||
| spelling != &case.input.text && spelling.eq_ignore_ascii_case(&case.input.text), | ||
| "{}: {spelling} is not the input's text in another letter case", | ||
| case.id | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
minor A case with expected_error may list spellings, and no runner ever reads them: Rust continues at the expected_error branch before the spelling loop, Go returns before its loop (conformance_test.go:257), and both corpusUuids() copies drop error cases. Adding a spelling to query-uuid-for-bytes passes every runner unread. Also require case.expected_error.is_none() when spellings is non-empty here, in Go at conformance_test.go:215, and in the parity test.
Source: code-review (medium); verified by review-cross-check · claude-opus-5-5
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 87b03c3. A refused case with spellings now fails in three places:
- the Rust runner's corpus check
- the Go runner's corpus check (
conformance_test.go) - a new parity test,
finds spellings only on accepted UUID cases
To check this, I added a spelling to query-uuid-for-bytes. All three failed. The two runners said "only an accepted case with a UUID input has other spellings". Then I restored the file. The README says the same.
| if cfg!(not(feature = "uuid")) && case.input.kind == "uuid" { | ||
| eprintln!("conformance: {}: skipped, needs the uuid feature", case.id); | ||
| continue; | ||
| } |
There was a problem hiding this comment.
minor (nit) Without the uuid feature this skips the whole accepted UUID case, including record::encrypt, query_term and record::decrypt, which need no feature (common::conformance::value builds the UUID frame ungated). So --no-default-features --features dynamic passes without checking the dynamic UUID path, and the only signal is an eprintln that nextest hides. Skip only scalar()/open_scalar and the spellings, taking the artifact ciphertext from the record's c leaf.
Source: code-review (medium) + spec agent; verified by review-cross-check · claude-opus-5-5
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 87b03c3. Without the uuid feature, an accepted UUID case now runs record::encrypt, record::decrypt, query_term, and both record cross-opens. It also compares the frame and the equality term with the frozen ones. The case skips only the owned scalar seal and open, and the spellings. Its fresh ciphertext is the record's c leaf.
cargo test -p stack-encrypt --no-default-features --features dynamic --test conformance passes, and logs "checking the record path" for the three UUID cases. Clippy with -D warnings is clean for that feature set. An update without the feature still fails, because the owned scalar API made the ciphertexts in the expected file.
| fn try_unhex(text: &str) -> Result<Vec<u8>, String> { | ||
| if !text.is_ascii() || !text.len().is_multiple_of(2) { | ||
| return Err("not hex".into()); | ||
| } | ||
| (0..text.len()) | ||
| .step_by(2) | ||
| .map(|i| u8::from_str_radix(&text[i..i + 2], 16).map_err(|e| e.to_string())) | ||
| .collect() | ||
| } |
There was a problem hiding this comment.
minor try_unhex repeats common::unhex (tests/common/mod.rs:378) apart from returning Err. Move it into common and have unhex call try_unhex(text).expect("hex").
Source: mattpocock-skills:code-review standards agent; verified by review-cross-check · claude-opus-5-5
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 87b03c3. try_unhex is now in tests/common/mod.rs, and unhex calls try_unhex(text).expect("hex"). The runner imports it from there.
| fn parse_uuid(text: &str) -> uuid::Uuid { | ||
| uuid::Uuid::try_parse(text).expect("a hyphenated UUID") | ||
| } | ||
|
|
There was a problem hiding this comment.
minor This lenient parse_uuid (any case, braced, simple, urn) shares its name with the strict canonical parse_uuid in tests/common/conformance.rs:209. Rename this one, for example read_spelling; the expect("a hyphenated UUID") message also overstates what try_parse requires.
Source: mattpocock-skills:code-review standards agent; verified by review-cross-check · claude-opus-5-5
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 87b03c3. The runner's lenient reader is now read_uuid_text, and its doc comment says which texts reach it. Its message is now "a UUID". The strict corpus reader in tests/common/conformance.rs keeps the name parse_uuid.
| async fn reopens( | ||
| keyset: &KeysetCipher<'_, common::DeterministicSource>, | ||
| corpus: &Corpus, | ||
| case: &Case, | ||
| plan: &record::Plan, | ||
| candidate: &Artifact, | ||
| (input, row): (&OwnedFrame, &OwnedFrame), | ||
| context: &Label, | ||
| ) -> Result<(), String> { |
There was a problem hiding this comment.
minor reopens takes seven parameters, one an ad-hoc (input, row) tuple that keeps it under clippy's too_many_arguments; corpus is used only for corpus.field and case only for case.kind. Pass field: &str and kind: &str, or a small struct for the expected input and row.
Source: mattpocock-skills:code-review standards agent; verified by review-cross-check · claude-opus-5-5
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 87b03c3. reopens is now Opening::check(&self, candidate). The Opening struct has the keyset, the plan, the context, the field name, and the kind. It also has the expected input and row, and whether the owned scalar API is available. try_stored and stored now take the field name instead of the corpus.
| let unchanged = previous | ||
| .as_ref() | ||
| .and_then(|p| p.cases.get(&case.id)) | ||
| .filter(|old| old.frame == artifact.frame && old.equality == artifact.equality); |
There was a problem hiding this comment.
minor unchanged is an Option<&Artifact> holding the previous artifact but reads as a boolean; frozen holds fresh artifacts under all or after a fallback. Rename, for example previous_match and written.
Source: mattpocock-skills:code-review standards agent; verified by review-cross-check · claude-opus-5-5
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 87b03c3. unchanged is now previous_match, with a comment saying it is the previous artifact whose frame and equality term match. frozen is now written, the map an update writes to the expected file.
These changes address the second review of the UUID cases. The Rust and Go runners, and the frame parity test, now refuse `spellings` on a refused case. No runner read them there. A Rust build without the uuid feature now runs the record path and the equality term of each UUID case. It skips only the owned scalar API and the spellings, and takes its fresh ciphertext from the record's leaf. The hex reader that can fail moves into the shared test helpers, and `unhex` calls it. The runner's UUID reader is renamed, so that it no longer shares a name with the strict corpus reader. One struct now holds what a ciphertext must open to. Two variables have clearer names. Refs #1821
Brings in #2011 and its single-value profile. - coverage.md: both sides changed one row of the table. This branch changed the row about scalar widths, and next changed the row about owned ciphertexts. The merge keeps both rows as they were changed. - Both sides added the same `uuid` input type to the shared conformance helper, tests/common/conformance.rs. Git merged the two copies into one. - The single-value contract defines the `uuid` input text as this branch's README does: lowercase hex in groups of 8, 4, 4, 4, and 12 digits.
Summary
The engine's value model takes a UUID, but no conformance case held one. So nothing checked that Rust, Go, and TypeScript write the same UUID frame and derive the same equality term. This pull request adds UUID cases to the scalar profile,
record-scalars-v1.The Rust engine froze the frame, the equality term, and a ciphertext of each case. Native Rust and Go run every case. The TypeScript value bridge checks the frames. The TypeScript runner of the whole profile is pending, because the addon cannot store a UUID until #1996 merges.
This is step 3 of #1821. Step 4 is still open, so this pull request does not close the issue. Step 4 adds a UUID to the Go generated code and the TypeScript addon.
Changes
conformance/stack-encrypt/v1/record-scalars-v1.cases.json: three accepted cases and five refused ones.uuid(123e4567-e89b-12d3-a456-426614174000),uuid-nil(all zeros), anduuid-max(all ones).uuidanduuid-maxlist the same UUID in uppercase, anduuidalso in mixed case, under a newspellingskey.query-text-for-uuid,query-bytes-for-uuid,query-uuid-for-bytes, andquery-uuid-for-stringare refused asfield_type.query-uuid-nullis refused asnull_query. So the engine converts nothing to or from a UUID.record-scalars-v1.expected.rust-native.json: the frame, equality term, and ciphertext of each new case, written by the Rust runner withSTACK_CONFORMANCE_UPDATE=1. Each normal run compares the engine's output with these values, so they cannot drift.packages/stack-encrypt/tests/conformance.rs: the runner seals and opens avalue::Uuid, and checks each spelling. An update now keeps the frozen ciphertext of a case whose frame and equality term have not changed. So adding these cases added three entries and left the other ciphertexts as they were.packages/stack-encrypt/tests/common/conformance.rs: theuuidinput type. The code is the same as in feat(stack-encrypt)!: encrypt and decrypt one value known only at run time, and bound the typed decrypt to a scalar #2011, so the two pull requests should merge without a conflict there.languages/golang/encrypt/conformance_test.go: the Go runner builds avcvalue.UUID, and checks each spelling withvcvalue.ParseUUID.languages/typescript/packages/recipher-js/value-napi/tests/frames.cjsand its two fixture files: sixVcUuidvalues, from every case and spelling, compared with the frozen frames. The fixtures were regenerated withRECIPHER_UPDATE_FIXTURES=1.conformance/stack-encrypt/README.mdandcoverage.md: the new input type, thespellingskey, the cases, and which runners run them.No changeset: the pull request changes tests, test data, and conformance documents only. No published package changes.
Verification
Run in a worktree on this branch:
cargo test -p stack-encrypt --all-features --test conformance: passes, with and withoutSTACK_CONFORMANCE_UPDATE=1.--test value_conformanceand--test runtime_conformancealso pass, because they share the changed helper.STACK_CONFORMANCE_OUTPUT, open in Rust withSTACK_CONFORMANCE_INPUT.go vet ./encryptandgofmt -l: clean. The Go selection thattest:conformanceruns passes, against both guests built from this branch.cargo test -p recipher-value-napi --test node: passes in check mode after the fixtures were regenerated.cargo fmt --checkandcargo clippy -p stack-encrypt --all-features --all-targets -D warnings: clean.pnpm run test:scripts: 99 files pass, including the conformance-suite checks and the TypeScript frame parity test.checkon the changed JSON and JavaScript: clean.Not run:
mise run test:conformanceas one task (mise is not trusted in the worktree), so I ran its steps by hand as listed above. I did not build the EQL guest, so I did not run the whole Go./encryptpackage. This pull request does not touch the tests that need it.Related
Refs #1821 (step 3).
uuidinput type for the single-value profile.Review notes
VcUuidtoRcUuidinframes.cjs. Whichever merges second needs a small rebase there and a regeneratedjs-frames.json.spellings. Only a host that reads UUID text checks them. The engine reads no UUID text.